AddCSLuaFile( "cl_init.lua" ) --Tell the server that the client needs to download cl_init.lua
AddCSLuaFile( "shared.lua" ) --Tell the server that the client needs to download shared.lua
 
include( 'zombies.lua' ) --Tell the server to load shared.lua
include( 'shared.lua' ) --Tell the server to load shared.lua
include( 'scavanger.lua' ) //This too.
include( 'scout.lua' ) //This too.
include( 'stats.lua' )
include( 'sql_database.lua' )
include( "cl_init.lua" )

--function GM:PlayerLoadout( ply ) // What should the player recieve when joining a team?
 --end
 
-- What happens when a player spawns

function GM:PlayerSpawn( ply )
    self.BaseClass:PlayerSpawn( ply )   
 
    ply:SetGravity  ( 1 ) 
    ply:SetMaxHealth( 100, true )  
 
    ply:SetWalkSpeed( 325 )  
    ply:SetRunSpeed ( 325 ) 
end

function GM:PlayerInitialSpawn( ply )  // When spawning after joining the sever
		
		joining( ply ) //Call the function joining (found near the bottom of this file)
		RunConsoleCommand( "sb_start" )	 //Run the console command defined in cl_init.lua. 	
		SetPlayerStats( ply ) // Calls the function in stats.lua that sets up the palyer for the stats system
 
end
hook.Add( "PlayerInitialSpawn", "PlayerInitialSpawn", PlayerInitialSpawn )
//hook.Add( "Initialize", "Initialize", Initialize )

 
function GM:PlayerLoadout( ply ) 
	if ply:Team() == 2 then 
		Scavanger( ply )
	elseif ply:Team() == 3 then 
		Scout( ply )
	else
		ply:Give( "weapon_crowbar" )
	end //right here.

end 
function sb_team1( ply ) 

	Scavanger( ply ) 
	ply:Spawn() // Spawn him
	ply:PrintMessage( HUD_PRINTTALK, "[Outbreak]I recognize you as a Scavanger " .. ply:Nick() ) //Again, a message in the talk area. 
	func()

 
end 

function sb_team2( ply )

	Scout( ply )
	ply:Spawn() // Spawn him
	ply:PrintMessage( HUD_PRINTTALK, "[Outbreak]I recognize you as a Scout, " .. ply:Nick() ) //Again, a message in the talk area.
	func()
 
end //End this function

concommand.Add( "sb_team1", sb_team1 ) //Now, we make sure that when we enter sb_team1 into console that it calls the function.
concommand.Add( "sb_team2", sb_team2 ) //Now, we make sure that when we enter sb_team2 into console that it calls the function. 
 
 function joining( ply ) --Sets teh player up to load the menu for choosign a team.
 
	ply:Spectate( 4 ) //Set him to spectate in free-roam mode. He doesn't actually fly around, since he has a window open at this point.
	ply:SetTeam( 1 ) //Set his team to Joining
 
end //End the function
 